<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ProductsViewModel>" %>
<%@ Import Namespace="Northwinddemo.BusinessLayer" %>

<% 
Html.Grid(Model.Products).Columns(column =>
    {
        column.For(p => p.ProductName).Action(a =>
        { %>
            <td>
            <%= Html.ActionLink<ProductsController>(p => p.Details(a.ProductId), a.ProductName)%>
            </td>                        
          <%
        });
        column.For(p => p.Suppliers).Action(a =>
        { %>
            <td>
            <%= NorthwinddemoHelper.GetSupplierDescription(a.Suppliers) %>
            </td>                        
          <%
        });
        column.For(p => p.Categories).Action(a =>
        { %>
            <td>
            <%= NorthwinddemoHelper.GetCategoryDescription(a.Categories)%>
            </td>                        
          <%
        });
        column.For(p => p.QuantityPerUnit);
        column.For(p => p.UnitPrice);
        column.For(p => p.UnitsInStock);
        column.For(p => p.UnitsOnOrder);
        column.For(p => p.ReorderLevel);
        column.For(p => p.Discontinued);
    })
    .Attributes(
        border => "1",
        style => "border-collapse: collapse;",
        width => "100%"
    ).Render();
%>
<br />    
<%= Html.Pager(Model.Products).Link(p => Url.Action("Index", new { page = p })).Format("Showing {0} - {1} of {2} &nbsp;&nbsp;")%>
